home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 10
/
FM Towns Free Software Collection 10.iso
/
ms_dos
/
tool
/
txf
/
src
/
txfmain.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-17
|
2KB
|
125 lines
/*====================================================================
*
* TXF mail module
*
*====================================================================
* copyright(C) 1992-1994 T.Nakatani
*====================================================================
*/
#define MAIN 1
#include "txf.h"
#define MAX_ARGV 32
#define VERSION "Ver2.11"
char far *fargv[MAX_ARGV];
void init(char *name)
{
char *path;
path = ((strlen(name) > 26) ? jstrrchr(name,'\\')+1 : name);
fprintf(stderr,"%s " VERSION " copyright (c) 1992-1994 T.Nakatani\n", path);
tmpinfile = -1;
init_allswitch();
basedir=name;
kl = NULL;
kf = NULL;
kq = NULL;
}
void setdefault()
{
/*
if (right > 0) right --;
if (maxc > 0) maxc --;
*/
if (cent > 0) {
if (left < 0) left = (maxc - cent) / 2;
if (right < 0) right = (maxc + cent) / 2;
}
if (maxc > 2000) {
maxc = 2000;
if (viewmode > 1) {
fprintf(stderr,"Warning:Too long right limit. limit is resetting 2000.\n");
}
}
if (left < 0) left = 0;
if ((right < 0) || (right > maxc)) right = maxc - 4;
#ifdef DEBUG
if (viewmode > 2)
fprintf(stderr,
"\x1b[31mWarning:This is debug mode for nobody. (mode=%d)\x1b[0m\n",
viewmode);
#endif
if (kl == NULL) {
kl = calloc(1, 1);
}
if (kf == NULL) {
kf = calloc(1, 1);
}
if (kq == NULL) {
kq = calloc(1, 1);
}
if ((kl == NULL) || (kf == NULL) || (kq == NULL)) {
errexit("Heap Error at(setdefault)");
}
}
void txf()
{
if (removeeofflg) removeeof();
if (exflg) exchangedriver();
if (format) {
if (base == 0) setleft0(); /* 自動検索 */
if (base > 0) setleft();
txform();
}
input_to_output();
}
void endoftxf()
{
remove(tfile[0]);
remove(tfile[1]);
if (*outputfile == NUL) {
fprintf(stderr, "\n");
}
}
int main(int argc, char **argv)
{
int i;
init(argv[0]);
setdefault();
if (tfile[0][0] == NUL) gettmpfile();
mktfilename();
command_option = 1;
if (argc > MAX_ARGV) {
errexit("too many command line arguments.");
}
else {
for (i = 0; i < argc - 1; i++) {
fargv[i] = argv[i+1];
}
fargv[i] = NULL;
}
swchk(argc - 1, fargv);
command_option = 0;
if (read_def_flg) read_def(argv[0]);
setdefault();
while (wcchk()) txf();
endoftxf();
return (0);
}